/**
 * Created by win7 on 2017/3/14.
 */
/**
 * Created by yoyoyk on 2017/3/8.
 */
import React, {Component} from "react";
import {Modal} from "antd";
import InputBox from "../../common/InputBox.js";
import Confirm from "../../common/Confirm";
import UpdateEnterpriseStatusMutation from "./mutation/UpdateEnterpriseStatusMutation"
import Relay from "react-relay";

/*业务平台>人员管理>编辑部门*/

export default class ForbidComapny extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            visible: false,
            companyName: '',
            companyId: '',
            status: ''
        }
        this.Style = {};
    }

    componentWillMount() {
        this.props.forbidCompany();
        this.setState({
            setdefault: this.props.setdefault
        });
        this.setState({
            partid: this.props.partid
        })
        this.Style.addpersonview = {
            textAlign: "center",
            display: "block",
            border: "3px solid green"
        }
        this.Style.addpersonview.width = 400;
        this.Style.addpersonview.height = 200;
        this.Style.addpersonview.fontSize = 30;

        this.Style.addpersonview = {
            width: "634px",
            height: "44px",
            paddingLeft: "18px",
            lineHeight: "44px",
            display: "block",
            background: "#f2f2f2",
            marginBottom: 49
        }
    }

    componentDidMount() {
    }

    updateStatus() {
        let status;
        if (this.state.status == 0) {
            status = 1;
        } else {
            status = 0;
        }

        Relay.Store.commitUpdate(
            new UpdateEnterpriseStatusMutation({
                //放传给后台参数的地方
                enterpriseIds: this.state.companyId,
                reason: this.refs.forbiddescription.state.text,
                status: status
            }),
            {
                onFailure: () => {
                    alert("失败");
                },
                onSuccess: (response) => {
                    let data = response.updateEnterpriseStatus.data;
                    console.log(data.value)
                    this.handleCancel();
                }
            });
    }


    state = {visible: false}
    showModal = () => {
        this.setState({
            visible: true,
        });

    }
    handleOk = (e) => {
        this.setState({
            visible: false,
        });
    }
    handleCancel = (e) => {
        this.setState({
            visible: false,
        });
    }

    forbidCompany() {
        this.updateStatus();
    }

    handleclick() {
        this.props.functest();
    }

    setname(name, description) {
        this.refs.partname.setState({
            text: name
        });
        this.refs.partdescription.setState({
            text: description || ''
        });
    }

    render() {
        return (
            <div>
                <Modal visible={this.state.visible} onOk={this.handleOk} onCancel={this.handleCancel}
                       style={{width: "634px", height: "240px", display: "block"}} title={"禁用"}>
                    <div style={{position: "absolute", left: 66, top: -30}}>
                        <span>企业名称：</span><span>{this.state.companyName}</span></div>
                    <span> style={{display: "none"}} {this.state.companyId}</span>
                    <InputBox multiline defaultvalute="内容最多不得超过200个字。" titletext="" space="12px" style={{
                        width: 338,
                        height: 115,
                        borderColor: "#d7d7d7",
                        color: "#999",
                        marginTop: 50,
                        paddingRight: 123,
                        paddingLeft: 100
                    }} ref={'forbiddescription'}/>
                    <Confirm tcontext="禁用" style={{
                        width: 266,
                        height: 42,
                        display: "block",
                        color: "#fff",
                        fontSize: "16px",
                        marginTop: 60,
                        marginLeft: 158
                    }} touch={this.forbidCompany.bind(this)}/>
                    <span style={{position: "absolute", left: 64, top: 0, width: 84, height: 18}}>*禁用原因</span>
                </Modal>
            </div>
        )
    }
}




